<style lang="less" scoped>

</style>

<template>
  <div>
    <div class="f-mt f-wa f-mb10">
      <ue-search-bar ref="ueSearchBar" v-model="searchForm" :data="querys" label-width="120px">
      </ue-search-bar>
      <el-button type="primary" class="f-wa" @click="createClickNetWork('networkManagement')">新增网点
      </el-button>
      <el-button type="primary" class="f-wa f-fr f-ml10 f-mr20" @click="$refs.ueSearchBar.reset()">重置</el-button>
      <el-button type="primary" class="f-wa f-fr f-ml10" @click="searchNetworkManagementForm">查询</el-button>
      <el-button type="primary" class="f-wa f-fr f-ml10 f-mr20" @click="exportNetWork">导出</el-button>
    </div>
    <el-table
      :data="networkManagement" border style="width: 100%">
      <el-table-column prop="netWorkNumber" label="网点编号" width="180"></el-table-column>
      <el-table-column prop="netWorkName" label="网点名称" width="180"></el-table-column>
      <el-table-column prop="netWorkTypeName" label="网点类型" width="120"></el-table-column>
      <el-table-column prop="mappingManner" label="匹配方式" width="120"></el-table-column>
      <el-table-column prop="affiliationOrganizationNames" show-overflow-tooltip label="归属组织"></el-table-column>
      <el-table-column prop="netWorkAddressNames" label="网点地址"></el-table-column>
      <el-table-column prop="principal" label="负责人" width="110"></el-table-column>
      <el-table-column prop="principalPhone" label="联系电话" width="130"></el-table-column>
      <el-table-column prop="statusName" label="状态" width="100"></el-table-column>
      <el-table-column prop="operation" label="操作">
        <template slot-scope="scope">
          <el-button type="success" class="f-wa f-ml10 f-mt5 f-mb5" @click="changeStatus(scope.row,111002001)"
                     v-if="scope.row.status===111002002">启用
          </el-button>
          <el-button type="warning" class="f-wa f-ml10 f-mt5 f-mb5" @click="changeStatus(scope.row,111002002)"
                     v-if="scope.row.status===111002001">禁用
          </el-button>
          <el-button type="primary" class="f-wa f-ml10 f-mt5 f-mb5" v-if="scope.row.status===111002002"
                     @click="modifNetworkManagementClick(scope.row)">
            编辑
          </el-button>
          <el-button type="danger" class="f-wa f-ml10 f-mt5 f-mb5" v-if="scope.row.status===111002002"
                     @click="deleteNetworkManagementClick(scope.row)">删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination class="f-mt10"
                   :current-page="currentPage"
                   :page-size="pageSize"
                   @size-change="handleSizeChange"
                   @current-change="handleCurrentChange"
                   layout="total,sizes,prev, pager, next, jumper"
                   :total="total" style="float: right">
    </el-pagination>
    <el-dialog :title="netWorkDialogTitle" :visible.sync="netWorkDialog">
      <el-form :model="networkManagementForm" ref="networkManagementForm" label-width="80px">
        <el-form-item label="网点名称" prop="netWorkName" :rules=" { required: true, message: '请输入网点名称', trigger: 'blur' }">
          <el-input class="f-w50" v-model="networkManagementForm.netWorkName"></el-input>
        </el-form-item>
        <el-form-item label="网点类型" prop="netWorkType" :rules=" { required: true, message: '请选择网点类型', trigger: 'blur' }">
          <el-select class="f-w50" v-model="networkManagementForm.netWorkType" clearable placeholder="请选择">
            <el-option label="自送网点" value="105002002"></el-option>
            <el-option label="自提网点" value="105001002"></el-option>
            <el-option label="自送自提" value="105001003"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="匹配方式" prop="mappingManner"
                      :rules=" { required: true, message: '请选择匹配方式', trigger: 'blur' }">
          <el-radio-group class="f-w50" v-model="networkManagementForm.mappingManner">
            <el-radio label="按起运地">按起运地</el-radio>
            <el-radio label="按目的地">按目的地</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item
          :rules=" { required: true, type: 'array', message: '请选择归属组织', trigger: 'blur' }"
          v-for="(domain, index) in networkManagementForm.affiliationOrganizationArray"
          :label="'归属组织'"
          :key="domain.key"
          :prop="'affiliationOrganizationArray.' + index + '.value'">
          <el-cascader
            placeholder="请选择合同组织"
            class="f-w50"
            :options="$store.state.initOrganizations"
            :props="{label: 'name',value: 'id'}"
            change-on-select
            v-model="domain.value"
          ></el-cascader>
          <el-button v-if="networkManagementForm.affiliationOrganizationArray.length>1"
                     type="danger"
                     @click.prevent="removeDomain(domain)">删除
          </el-button>
          <el-button type="primary" @click="addDomain">新增</el-button>
        </el-form-item>
        <el-form-item label="负责人" prop="principal">
          <el-input class="f-w50" v-model="networkManagementForm.principal"></el-input>
        </el-form-item>
        <el-form-item label="联系电话" prop="principalPhone"
                      :rules=" {min:11, max:11, required: true, message: '请输入11位联系电话', trigger: 'change' }">
          <el-input class="f-w50" v-model="networkManagementForm.principalPhone" type="number"></el-input>
        </el-form-item>
        <el-form-item label="网点地址" prop="netWorkAddress"
                      :rules=" { required: true,type:'array', message: '请选择网点地址', trigger: 'blur' }">
          <address-select
            @getAddresses="getAddresses"
            v-model="networkManagementForm.netWorkAddress"
            placeholder="请选择地址"
            class="f-w50"></address-select>
          <address-update-warn
            v-if="networkManagementForm.netWorkAddress && networkManagementForm.id && networkManagementForm.netWorkAddress[3] == null">
          </address-update-warn>
        </el-form-item>
        <el-form-item label="详细地址" prop="street" :rules=" { required: true, message: '请输入详细地址', trigger: 'blur' }">
          <el-input class="f-w50" v-model="networkManagementForm.street"></el-input>
        </el-form-item>
        <el-form-item class="f-mb">
          <el-button type="primary" class="f-fr f-mb10" @click="createClickNetWork('networkManagementAddresses')">新 增
          </el-button>
        </el-form-item>
        <el-form-item label="覆盖范围">
          <el-table :data="networkManagementForm.networkAddressTOS" border style="width: 100%">
            <el-table-column prop="provinceName" label="包含省"></el-table-column>
            <el-table-column prop="cityName" label="包含市"></el-table-column>
            <el-table-column prop="countyName" label="包含县"></el-table-column>
            <el-table-column prop="notProvinceName" label="不包含省"></el-table-column>
            <el-table-column prop="notCityName" label="不包含市"></el-table-column>
            <el-table-column prop="notCountyName" label="不包含县"></el-table-column>
            <el-table-column prop="operation" label="操作">
              <template slot-scope="scope">
                <el-button type="primary" class="f-wa f-ml10 f-mt5 f-mb5"
                           @click="modifyNetworkManagementAddresses(scope.row,scope.$index)">修改
                </el-button>
                <el-button type="primary" class="f-wa f-ml10 f-mt5 f-mb5"
                           @click="deleteNetworkManagementAddress(scope.$index, networkManagementForm.networkAddressTOS)">
                  删除
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input type="textarea" class="f-w50" v-model="networkManagementForm.remark"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="netWorkDialog = false">取 消</el-button>
        <el-button type="primary" @click="createNetworkManagementClick">确 定</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="networkManagementAddressesTitle" size="tiny" :visible.sync="networkManagementAddressesDialog">
      <el-form :model="networkManagementAddressesForm" label-width="90px" ref="networkManagementAddressesForm">
        <el-form-item label="包含省" prop="provinces" :rules="{validator: this.networkManagementAddressesFormFun}">
          <el-cascader v-model="networkManagementAddressesForm.provinceIds"
                       placeholder="请选择省" :options="province"
                       change-on-select :props="props"></el-cascader>
        </el-form-item>
        <el-form-item label="包含市" prop="cityIds" :rules="{validator: this.cityFun}">
          <el-cascader v-model="networkManagementAddressesForm.cityIds" placeholder="请选择市" :options="city"
                       change-on-select :props="props"></el-cascader>
        </el-form-item>
        <el-form-item label="包含区" prop="countyIds" :rules="{validator: this.countyFun}">
          <el-cascader v-model="networkManagementAddressesForm.countyIds" placeholder="请选择区" :options="county"
                       change-on-select :props="props"></el-cascader>
        </el-form-item>
        <el-form-item label="不包含省">
          <el-cascader v-model="networkManagementAddressesForm.notProvinceIds" placeholder="请选择省" :options="province"
                       change-on-select :props="props"></el-cascader>
        </el-form-item>
        <el-form-item label="不包含市" prop="notCityIds" :rules="{validator: this.notCityFun}">
          <el-cascader v-model="networkManagementAddressesForm.notCityIds" placeholder="请选择市" :options="city"
                       change-on-select :props="props"></el-cascader>
        </el-form-item>
        <el-form-item label="不包含区" prop="notCountyIds" :rules="{validator: this.notCountyFun}">
          <el-cascader v-model="networkManagementAddressesForm.notCountyIds" placeholder="请选择区" :options="county"
                       change-on-select :props="props"></el-cascader>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="networkManagementAddressesDialog = false">取 消</el-button>
        <el-button type="primary" @click="createNetworkManagementAddressesClick">提 交</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { isEmpty, resetForm, getTreeIdAndNameToMap, resetObjNull, objToFilter } from '../../lib/util.js';
import { addressDicts } from '../../api/system/addressDict.js';
import {
  saveNetworkManagement,
  searchNetworkManagements,
  findNetworkManagement,
  deleteNetworkManagement,
  changeStatus
} from '../../api/basedata/networkManagementApi.js';
import AddressUpdateWarn from '../meb-user/AddressUpdateWarn.vue';

export default {
  components: {
    AddressUpdateWarn
  },
  data () {
    return {
      networkManagement: [],
      networkManagementForm: {
        netWorkName: '',
        netWorkType: '',
        mappingManner: '',
        netWorkAddress: [],
        netWorkAddressIds: '',
        affiliationOrganizationArray: [{
          value: []
        }],
        affiliationOrganizationIds: '',
        principal: '',
        principalPhone: '',
        networkAddressTOS: [],
        street: '',
        status: 111002002,
        statusName: '未启用',
        remark: ''
      },
      networkManagementAddressesForm: {
        provinceIds: [],
        provinceId: '',
        provinceName: '',
        cityIds: [],
        cityId: '',
        cityName: '',
        countyIds: [],
        countyId: '',
        countyName: '',
        notProvinceIds: [],
        notProvinceId: '',
        notProvinceName: '',
        notCityIds: [],
        notCityId: '',
        notCityName: '',
        notCountyIds: [],
        notCountyId: '',
        notCountyName: ''
      },
      province: [],
      city: [],
      county: [],
      props: {
        value: 'id',
        label: 'name'
      },
      netWorkDialogTitle: '新增网点',
      networkManagementAddressesTitle: '新增管辖范围',
      netWorkDialog: false,
      networkManagementAddressesDialog: false,
      addresses: [],
      index: '',
      searchForm: {},
      total: 0,
      currentPage: 1,
      pageSize: 10
    };
  },
  methods: {
    searchNetworkManagementForm () {
      this.currentPage = 1;
      this.searchCom();
    },
    searchCom () {
      let filters = '';
      let ob = Object.assign({}, this.searchForm);
      if (!isEmpty(ob.EQ_affiliationOrganizationIds)) {
        filters = 'LIKE_affiliationOrganizationIds=' + ob.EQ_affiliationOrganizationIds + ';';
        delete ob.EQ_affiliationOrganizationIds;
      }

      filters = filters + objToFilter(ob);
      console.log(filters);
      this.getNetworkManagements(filters);
    },
    exportNetWork () {
      // todo 导出请求添加权限问题
      // window.header.add('Authorization', 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImlkIjoiOGE5YjJlMDk1YTM2NTY1NTAxNWEzNjcyNjY2MTAwMDAiLCJhdXRoIjoiUk9MRV9VU0VSIiwiZXhwIjoxNTIwOTIxNTQ4fQ.iBmY0_QT20184fSC5PFB-uLtv--eIiqNWbnOCehv4_-nmgZf785_ymhsNfmdlBLwvZ3tbB-tZhin_oXrDssCdQ');
      // let xmlhttp = new XMLHttpRequest();
      // xmlhttp.open('GET', '/api/v3.0/admin/api/net-works/export?filters=' + this.fs);
      // xmlhttp.setRequestHeader('Authorization', '123');
      // xmlhttp.send();
      // window.location = '/api/v3.0/admin/api/net-works/export?filters=' + this.fs;
      location.href = '/api/v2.0/admin/net_work_managements/export?filters=' + this.fs;
    },
    getNetworkManagements (filters) {
      this.fs = filters;
      searchNetworkManagements({
        filters: filters,
        sort: 'createdDate,desc',
        size: this.pageSize,
        page: this.currentPage - 1
      }).then(res => {
        if (res.status === 200) {
          this.networkManagement = res.data;
          this.total = Number(res.headers['x-total-count']);
        }
      }).catch(err => {
        console.error(err);
      });
    },
    modifyNetworkManagementAddresses (row, index) {
      this.index = index;
      this.getAddress('level=1');
      this.getAddress('level=1,2');
      this.getAddress('level=1,2,3');
      this.networkManagementAddressesDialog = true;
      this.networkManagementAddressesForm = row;
      this.toArray(row.provinceId, data => {
        this.networkManagementAddressesForm.provinceIds = data;
      });
      this.toArray(row.cityId, data => {
        this.networkManagementAddressesForm.cityIds = data;
      });
      this.toArray(row.countyId, data => {
        this.networkManagementAddressesForm.countyIds = data;
      });
      this.toArray(row.notProvinceId, data => {
        this.networkManagementAddressesForm.notProvinceIds = data;
      });
      this.toArray(row.notCityId, data => {
        this.networkManagementAddressesForm.notCityIds = data;
      });
      this.toArray(row.notCountyId, data => {
        this.networkManagementAddressesForm.notCountyIds = data;
      });
    },
    deleteNetworkManagementAddress (index, rows) {
      this.networkManagementForm.networkAddressTOS.splice(index, 1);
    },
    createNetworkManagementClick () {
      this.$refs['networkManagementForm'].validate((networkManagementValid) => {
        if (networkManagementValid) {
          let orgIds = '';
          let orgNames = '';
          this.networkManagementForm.affiliationOrganizationArray.map(orgId => {
            orgIds = orgIds + orgId.value.toString() + ';';
            let objects = getTreeIdAndNameToMap(orgId.value, this.$store.state.initOrganizations);
            if (!isEmpty(orgNames)) {
              orgNames = orgNames.substring(0, orgNames.length - 1) + '; ';
            }
            for (let i = 0; i < objects.toJSON().length; i++) {
              orgNames = orgNames + objects.toJSON()[i][1] + ',';
            }
          });
          if (this.networkManagementForm.netWorkAddress[3] == null) {
            return this.$message.error('请选择到乡/镇/街道一级地址');
          }
          let seAddressIds = this.networkManagementForm.netWorkAddress;
          this.networkManagementForm.netWorkAddressIds = seAddressIds.toString();
          console.log(this.addresses);
          this.networkManagementForm.netWorkAddressNames = getTreeIdAndNameToMap(seAddressIds, this.addresses).get(seAddressIds[0]) + ',' + getTreeIdAndNameToMap(seAddressIds, this.addresses).get(seAddressIds[1]) + ',' + getTreeIdAndNameToMap(seAddressIds, this.addresses).get(seAddressIds[2]) + (isEmpty(seAddressIds[3]) ? '' : ',' + getTreeIdAndNameToMap(seAddressIds, this.addresses).get(seAddressIds[3]));
          this.networkManagementForm.affiliationOrganizationIds = orgIds;
          if (isEmpty(this.networkManagementForm.netWorkNumber)) {
            this.networkManagementForm.netWorkNumber = 'WD' + new Date().getTime();
          }
          this.networkManagementForm.affiliationOrganizationNames = orgNames;
          this.networkManagementForm.netWorkTypeName = this.getType(this.networkManagementForm.netWorkType, data => {
            return data;
          });
          saveNetworkManagement(this.networkManagementForm).then(res => {
            if (res.status === 201) {
              this.$message.success('新增/编辑成功');
              this.netWorkDialog = false;
              this.$refs['networkManagementForm'].resetFields();
              this.searchCom();
            } else {
              this.$message.error('新增/编辑失败');
            }
          }).catch(err => {
            console.error(err);
          });
        }
      });
    },
    deleteNetworkManagementClick (row) {
      this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
        type: 'warning'
      }).then(() => {
        deleteNetworkManagement(row.id).then(res => {
          if (res.status === 200) {
            this.$message.success('删除成功');
            this.currentPage = 1;
            this.searchCom();
          }
        }).catch(err => {
          console.error(err);
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },
    changeStatus (row, status) {
      this.$confirm('是否确认修改该条数据的状态, 是否继续?', '提示', {
        type: 'warning'
      }).then(() => {
        changeStatus(row.id, status).then(res => {
          if (res.status === 200) {
            this.$message.success('修改成功');
            this.searchCom();
          } else {
            this.$message.error('修改失败');
          }
        }).catch(err => {
          console.error(err);
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消修改'
        });
      });
    },
    removeDomain (item) {
      var index = this.networkManagementForm.affiliationOrganizationArray.indexOf(item);
      if (index !== -1) {
        this.networkManagementForm.affiliationOrganizationArray.splice(index, 1);
      }
      this.setR(this.networkManagementForm.remark);
    },
    addDomain () {
      this.networkManagementForm.affiliationOrganizationArray.push({
        value: [],
        key: Date.now()
      });
      this.setR(this.networkManagementForm.remark);
    },
    setR (val) {
      this.networkManagementForm.remark = ' ';
      this.networkManagementForm.remark = val;
    },
    createNetworkManagementAddressesClick () {
      this.$refs['networkManagementAddressesForm'].validate((valid) => {
        if (valid) {
          let o = Object.assign({}, this.networkManagementAddressesForm);
          o = this.setAddress(o, data => {
            return data;
          });
          if (!isEmpty(this.index)) {
            this.networkManagementForm.networkAddressTOS.splice(this.index, 1);
          }
          this.index = '';
          console.log(this.networkManagementForm);
          this.networkManagementForm.networkAddressTOS.push(o);
          resetForm(this.$refs.networkManagementAddressesForm, this.networkManagementAddressesForm);
          this.networkManagementAddressesDialog = false;
        }
      });
    },
    networkManagementAddressesFormFun (rule, value, callback) {
      if (isEmpty(this.networkManagementAddressesForm.provinceIds) && isEmpty(this.networkManagementAddressesForm.cityIds) &&
          isEmpty(this.networkManagementAddressesForm.countyIds) && isEmpty(this.networkManagementAddressesForm.notProvinceIds) &&
          isEmpty(this.networkManagementAddressesForm.notCityIds) && isEmpty(this.networkManagementAddressesForm.notCountyIds)) {
        return callback(new Error('至少选择一项才能保存'));
      }
      callback();
    },
    cityFun (rule, value, callback) {
      if (!isEmpty(this.networkManagementAddressesForm.cityIds) && this.networkManagementAddressesForm.cityIds.length < 2) {
        return callback(new Error('请选择到市'));
      }
      callback();
    },
    notCityFun (rule, value, callback) {
      if (!isEmpty(this.networkManagementAddressesForm.notCityIds) && this.networkManagementAddressesForm.notCityIds.length < 2) {
        return callback(new Error('请选择到市'));
      }
      callback();
    },
    countyFun (rule, value, callback) {
      if (!isEmpty(this.networkManagementAddressesForm.countyIds) && this.networkManagementAddressesForm.countyIds.length < 3) {
        return callback(new Error('请选择到区'));
      }
      callback();
    },
    notCountyFun (rule, value, callback) {
      if (!isEmpty(this.networkManagementAddressesForm.notCountyIds) && this.networkManagementAddressesForm.notCountyIds.length < 3) {
        return callback(new Error('请选择到区'));
      }
      callback();
    },
    createClickNetWork (val) {
      if (val === 'networkManagementAddresses') {
        this.networkManagementAddressesDialog = true;
        resetForm(this.$refs.networkManagementAddressesForm, this.networkManagementAddressesForm);
        this.getAddress('level=1');
        this.getAddress('level=1,2');
        this.getAddress('level=1,2,3');
      } else if (val === 'networkManagement') {
        this.netWorkDialog = true;
        this.networkManagementForm.networkAddressTOS = [];
        resetObjNull(this.networkManagementForm);
        this.addDomain();
      }
    },
    modifNetworkManagementClick (row) {
      this.netWorkDialog = true;
      this.networkManagementForm.networkAddressTOS = [];
      resetObjNull(this.networkManagementForm);
      findNetworkManagement(row.id).then(res => {
        if (res.status === 200) {
          this.networkManagementForm = res.data;
          let array = [];
          this.networkManagementForm.affiliationOrganizationIds.split(';').forEach(strings => {
            if (!isEmpty(strings)) {
              array.push({value: strings.split(','), key: Date.now()});
            }
          });
          this.networkManagementForm.affiliationOrganizationArray = array;
          this.toArray(res.data.netWorkAddressIds, data => {
            this.networkManagementForm.netWorkAddress = data;
          });
          console.log(this.networkManagementForm);
          this.networkManagementForm.netWorkType = res.data.netWorkType.toString();
        }
      });
    },
    getAddress (filters) {
      addressDicts(filters).then(res => {
        let address = res.data.detailModelList;
        if (filters === 'level=1') {
          this.province = address;
        }
        if (filters === 'level=1,2') {
          this.city = address;
        }
        if (filters === 'level=1,2,3') {
          this.county = address;
        }
      }).catch(err => {
        console.error(err);
      });
    },
    setAddress (o, fun) {
      if (!isEmpty(o.provinceIds)) {
        o.provinceName = getTreeIdAndNameToMap(o.provinceIds, this.province).get(o.provinceIds[0]);
        o.provinceId = o.provinceIds.join(',');
      }
      if (!isEmpty(o.cityIds)) {
        let cityModel = getTreeIdAndNameToMap(o.cityIds, this.city);
        o.cityName = cityModel.get(o.cityIds[0]) + ',' + cityModel.get(o.cityIds[1]);
        o.cityId = o.cityIds.join(',');
      }
      if (!isEmpty(o.countyIds)) {
        let countyModel = getTreeIdAndNameToMap(o.countyIds, this.county);
        o.countyName = countyModel.get(o.countyIds[0]) + ',' + countyModel.get(o.countyIds[1]) + ',' + countyModel.get(o.countyIds[2]);
        o.countyId = o.countyIds.join(',');
      }
      if (!isEmpty(o.notProvinceIds)) {
        o.notProvinceName = getTreeIdAndNameToMap(o.notProvinceIds, this.province).get(o.notProvinceIds[0]);
        o.notProvinceId = o.notProvinceIds.join(',');
      }
      if (!isEmpty(o.notCityIds)) {
        let notCityModel = getTreeIdAndNameToMap(o.notCityIds, this.city);
        o.notCityName = notCityModel.get(o.notCityIds[0]) + ',' + notCityModel.get(o.notCityIds[1]);
        o.notCityId = o.notCityIds.join(',');
      }
      if (!isEmpty(o.notCountyIds)) {
        let notCountyModel = getTreeIdAndNameToMap(o.notCountyIds, this.county);
        o.notCountyName = notCountyModel.get(o.notCountyIds[0]) + ',' + notCountyModel.get(o.notCountyIds[1]) + ',' + notCountyModel.get(o.notCountyIds[2]);
        o.notCountyId = o.notCountyIds.join(',');
      }
      return fun(o);
    },
    getAddresses (data) {
      this.addresses = data;
    },
    getType (type, fun) {
      type = parseFloat(type);
      if (type === 105002002) {
        return fun('自送网点');
      }
      if (type === 105001002) {
        return fun('自提网点');
      }
      if (type === 105001003) {
        return fun('自送自提');
      }
    },
    toArray (data, fun) {
      if (isEmpty(data)) {
        fun([]);
      } else {
        fun(data.split(',').map(function (dt) {
          return +dt;
        }));
      }
    },
    // 每页几条操作
    handleSizeChange (val) {
      this.pageSize = val;
      this.searchCom('');
    },
    // 第几页操作
    handleCurrentChange (val) {
      this.currentPage = val;
      this.searchCom('');
    }
  },
  mounted () {
    this.$store.commit('initDict');
    this.$store.commit('initOrganizations');
    this.getNetworkManagements('');
  },
  computed: {
    btns () {
      return this.$store.state.btns[this.$route.path] || [];
    },
    querys () {
      return this.$store.state.querys[this.$route.path + '#default'] || [];
    }
  }
};
</script>
